package com.module.app.emoji.view

import android.view.ViewGroup
import com.module.app.base.BaseListFragment
import com.module.app.emoji.model.TTEmojiViewModel
import com.module.app.ext.emojiSendBtnFlow
import com.module.base.base.adapter.BaseNewAdapter
import com.module.app.databinding.AppFragmentTtEmojiBinding
import com.module.base.base.adapter.BaseAdapter
import com.module.frame.ext.postEvent

class TTEmojiFragment :
    BaseListFragment<TTEmojiViewModel, AppFragmentTtEmojiBinding, BaseAdapter>() {

    override fun bingViewModel() {
        mDatabind.vm = mViewModel
    }

    override fun onLazyLoad() {
        TODO("Not yet implemented")
    }

    override fun createAdapter(): BaseAdapter {
        return object : BaseAdapter() {
            override fun onCreateDefaultViewHolder(
                parent: ViewGroup,
                viewType: Int
            ): com.module.app.emoji.adapter.holder.EmojiHolder {
                return com.module.app.emoji.adapter.holder.EmojiHolder(parent)
            }
        }
    }


    override fun initData() {
        super.initData()
        refresh2()
    }

    override fun initListener() {
        super.initListener()
        adapter.setOnItemClickListener(BaseNewAdapter.OnItemClickListener<com.module.app.emoji.adapter.holder.EmojiHolder?, com.module.app.emoji.bean.Emoji?> { _, bean ->
            postEvent(emojiSendBtnFlow,bean)
        })
    }

    override fun onListLoadPage(isPull: Boolean, isRefresh: Boolean, page_no: Int, page_size: Int) {
        mViewModel.getData()
    }

}